package com.example.fundappcation;

import androidx.appcompat.app.AppCompatActivity;

import android.content.IntentFilter;
import android.net.ConnectivityManager;
import android.os.Bundle;
import android.view.View;

import com.example.fundappcation.Base.BaseActivity;
import com.example.fundappcation.Receiver.NetWorkReceiver;
import com.example.fundappcation.databinding.ActivityMainBinding;

public class MainActivity extends BaseActivity {
    private ActivityMainBinding mainBinding;
    private NetWorkReceiver netWorkReceiver;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        ((MyApplication) getApplicationContext()).getApplicationComponent().inject(this);
        super.onCreate(savedInstanceState);
    }

    @Override
    protected View initView() {
        mainBinding = ActivityMainBinding.inflate(getLayoutInflater());
        return mainBinding.getRoot();
    }

    @Override
    protected void init() {
        if (netWorkReceiver == null) {
            netWorkReceiver = new NetWorkReceiver();
        }

        IntentFilter intentFilter = new IntentFilter();
        intentFilter.addAction(ConnectivityManager.CONNECTIVITY_ACTION);
        registerReceiver(netWorkReceiver, intentFilter);

    }

    @Override
    protected void initLoad() {

    }

    @Override
    protected void initData() {

    }

    @Override
    protected void onDestroy() {
        super.onDestroy();
        unregisterReceiver(netWorkReceiver);
    }
}